package com.example.covid19.controller;


import com.example.covid19.common.lang.Result;
import com.example.covid19.entity.OrderForm;
import com.example.covid19.mapper.OrderFormMapper;
import com.example.covid19.mapper.OrderInfoMapper;
import com.example.covid19.mapper.OrderdtoMapper;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * VIEW 前端控制器
 * </p>
 *
 * @author BaiZhengChun
 * @since 2022-11-16
 */
@RestController
@RequestMapping("/orderdto")
public class OrderdtoController {
    private final OrderdtoMapper orderdtoMapper;
    private final OrderFormMapper orderFormMapper;
    private final OrderInfoMapper orderInfoMapper;

    public OrderdtoController(OrderdtoMapper orderdtoMapper, OrderFormMapper orderFormMapper, OrderInfoMapper orderInfoMapper) {
        this.orderdtoMapper = orderdtoMapper;
        this.orderFormMapper = orderFormMapper;
        this.orderInfoMapper = orderInfoMapper;
    }

    @PostMapping("/Oinf2")
    public Result Oinf2(@RequestParam("pageNo") Integer pageNo,@RequestParam("pagesize")Integer pagesize){
        int a = (pageNo-1)*pagesize;
        return Result.success(200,"成功",orderInfoMapper.getps(a,pagesize));

    }
    @PostMapping("/Oinf")
    public Result Oinf(){
                Map<Object,Object> map = new HashMap<>(2);
        List<OrderForm> list = new ArrayList<>();
        list = orderFormMapper.selectList(null);
        map.put("orinf",list);
        map.put("count",orderFormMapper.selectCount(null));
        return Result.success(200,"成功",map);
//        return Result.success(200,"成功",)
    }
    @PostMapping("/odrdl")
    public Result usedl(@RequestParam("orderid") Integer userid) {
        return Result.success(200,"成功",orderdtoMapper.deleteById(userid));
    }
    @PostMapping("/ssinf")
    public Result ssinf(@RequestParam("ordernumber") String ordernumber) {
        return Result.success(200,"成功",orderInfoMapper.getof(ordernumber));
    }

}
